package com.michale.common.result;

import com.github.pagehelper.PageHelper;
import com.michale.common.utils.Sql.SQLFilterUtils;

/**
 * @author Michale
 * @apiNote 分页工具
 */
public class PageUtils extends PageHelper {

    /**
     * 设置请求分页数据
     */
    public static void startPage() {
        PageParam pageParam = PageParam.getPageParam();
        Integer pageNum = pageParam.getPageNum();
        Integer pageSize = pageParam.getPageSize();
        String orderBy = SQLFilterUtils.sqlInject(pageParam.getOrderBy());
        Boolean reasonable = pageParam.getReasonable();
        PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
    }

    /**
     * 清理分页的线程变量
     */
    public static void clearPage() {
        PageHelper.clearPage();
    }
}
